<?php include '../admin_head.php';
//获取分类信息
$sql = "select id,pid,name,path,concat(path,',',id) bpath from ".PRE."category order by bpath";
	$result = mysql_query($sql);
	if($result && mysql_num_rows($result)>0){
		while($row = mysql_fetch_assoc($result)){
			$row['name'] = str_repeat('&nbsp;&nbsp;',floor(strlen($row['path'])/2)).$row['name'];
			$catelist[] = $row;
		}
	}

//获取指定商品信息
$id = $_GET['id'];
$sql = "select cate_id,name,price,store,style,`describe` from ".PRE."goods where id={$id}";
$result = mysql_query($sql);
$goods = mysql_fetch_assoc($result);

$category = $_GET['cg'];
$style = $_GET['st'];
$page= $_GET['p'];
?>
	
		<div class="admin_main_nav">商品管理&gt;&gt;编辑商品</div>
		<div id="admin_addcate" class="admin_form admin_main_index">
		<div class="user_index_title"></div>
			<table width="500">
			<form action="action.php?a=edit&id=<?php echo $id?>&cg=<?php echo $category?>&st=<?php echo $style?>&p=<?php echo $page ?>" method="post" enctype="multipart/form-data">
				<tr>
					<th>所属分类：</th>
					<td>
						<select name="pid">
							<option value="0">顶级分类</option>
							<?php foreach($catelist as $tr):?>
							<option value="<?php echo $tr['id'] ?>" <?php echo $goods['cate_id'] == $tr['id'] ? 'selected': '' ; ?>><?php echo $tr['name'] ?></option>
							<?php endforeach;?>
						</select>
					</td>
				</tr>
				<tr>
					<th>商品名称：</th>
					<td><input type="text" name="name" value="<?php echo $goods['name']?>" /></td>
				</tr>
				<tr>
					<th>商品价格：</th>
					<td><input type="text" name="price" value="<?php echo $goods['price']?>"/></td>
				</tr>
				<tr>
					<th>商品数量：</th>
					<td><input type="text" name="store" value="<?php echo $goods['store']?>"/></td>
				</tr>
				<tr>
					<th>商品风格：</th>
					<td>
						<select name="style">
							<option value="0" <?php if($goods['style'] == 0) echo 'selected';?>>普通风格</option>
							<option value="1" <?php if($goods['style'] == 1) echo 'selected';?>>时尚内衣</option>
							<option value="2" <?php if($goods['style'] == 2) echo 'selected';?>>优雅女装</option>
							<option value="3" <?php if($goods['style'] == 3) echo 'selected';?>>休闲女装</option>
							<option value="4" <?php if($goods['style'] == 4) echo 'selected';?>>日韩女装</option>
							<option value="5" <?php if($goods['style'] == 5) echo 'selected';?>>欧式女装</option>
							<option value="6" <?php if($goods['style'] == 6) echo 'selected';?>>意式女装</option>
							<option value="7" <?php if($goods['style'] == 7) echo 'selected';?>>年轻潮牌</option>
							<option value="8" <?php if($goods['style'] == 8) echo 'selected';?>>高端男装</option>
						</select>
					</td>
				</tr>
				<tr>
					<th>商品图片：</th>
					<td><input type="file" name="pic" /></td>
				</tr>
				<tr>
					<th>商品描述：</th>
					<td><textarea name="describe" cols="30"><?php echo $goods['describe']?></textarea></td>
				</tr>
				<tr>
					<td colspan="2" class="submit">
						<input type="submit" value="更新商品" />
						<a href="image.php?<?php echo '&id='.$id.'&name='.$goods['name'];?>">详情图片</a>
					</td>
				</tr>
			</form>
		</table>
		</div>

		
<?php include '../admin_footer.php';?>

